Skip to content

Keep the lint files Codacy reads to packages Codacy installs - #178

Merged
PDowney merged 2 commits into
mainfrom
codacy-config-files
Nov 25, 2026
Merged

PDowney merged 2 commits into
mainfrom
codacy-config-files

Conversation

@PDowney

@PDowney PDowney commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Codacy reads phpcs.xml and phpmd.xml (the "Configuration file" setting is on for each), but it installs no WordPress coding standards, no PHPCSExtra, and only PHPMD 2. Codacy's analysis log for 6f04788 shows both tools failing:

  • PHPCS: Referenced sniff "WordPress-Extra" does not exist
  • PHPMD: crashes on LongMethodName, a PHPMD 3 rule

So Codacy checked none of the plugin's PHP with those tools.

Each tool now has a file Codacy can run and a full file that composer and CI run. The plugin's own checks are unchanged.

Tool Codacy reads Composer and CI run
PHPCS phpcs.xml: the rules from PHPCS's own standards and VariableAnalysis that the WordPress standards apply, with their exact settings and the 4-column tab width, plus PHPCompatibilityWP phpcs-wordpress.xml (the former phpcs.xml)
PHPMD phpmd.xml phpmd.xml plus phpmd-extra.xml (LongMethodName, 50 characters)

.github/scripts/codacy-configs.py regenerates the rules in phpcs.xml from phpcs-wordpress.xml. It reads PHPCS's loaded ruleset through .github/scripts/phpcs-ruleset-dump.php, a report class. The "Run PHPCS" step fails when the copy is out of date, for example after a Dependabot update to the WordPress standards.

Codacy still can't run any WordPress-specific rule; those keep running only in CI.

Testing

  • Generated phpcs.xml: no findings on the plugin. Its loaded ruleset matches phpcs-wordpress.xml for all 213 rules from Codacy-installed standards (same sniffs, properties, severities and types). Every listed sniff is in Codacy's PHPCS catalog. A test file triggers its indentation, spacing, docblock and unused-variable rules.
  • composer check-all (PHPCS, PHPMD, Psalm, PHPStan, Rector, 153 PHPUnit tests), markdownlint, Ruff, strict mypy, Bandit through Prospector, yamllint, actionlint, zizmor (no change) and gitleaks pass. A test file confirms LongMethodName fires through phpmd-extra.xml.

After merge, the Codacy log for the merge commit should show PHP_CodeSniffer and PHP Mess Detector as success.

🤖 Generated with Claude Code

Codacy reads phpcs.xml and phpmd.xml, but it installs no WordPress
coding standards, no PHPCSExtra, and only PHPMD 2, so every analysis
failed for both tools and Codacy checked no PHP with them.

- PHPCS: phpcs-wordpress.xml is the former phpcs.xml, which composer
  and CI run. phpcs.xml holds the rules from PHPCS's own standards and
  VariableAnalysis that the WordPress standards apply, with their
  settings and the tab width, plus PHPCompatibilityWP.
- PHPMD: LongMethodName, a PHPMD 3 rule, moves to phpmd-extra.xml;
  composer and CI pass both files.

.github/scripts/codacy-configs.py regenerates phpcs.xml's rules from
phpcs-wordpress.xml, and CI fails when they are out of date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codacy-production

codacy-production Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 44 complexity · 0 duplication

Metric Results
Complexity 44
Duplication 0

View in Codacy

🟢 Coverage ∅ diff coverage · +0.00% coverage variation

Metric Results
Coverage variation ✅ +0.00% coverage variation (-1.00%)
Diff coverage ✅ ∅ diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (6f04788) 877 663 75.60%
Head commit (88620b9) 877 (+0) 663 (+0) 75.60% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#178) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for contributing to EngineScript Site Optimizer!

Before we review:

  • Have you tested your changes with WordPress 7.0+?
  • Are your changes compatible with PHP 8.3+?
  • Have you followed WordPress coding standards?
  • Did you update the CHANGELOG.md if needed?

Security Reminder
This plugin stores per-site settings and emits browser resource hints, so please ensure:

  • All user input is properly sanitized
  • All output is properly escaped
  • No security vulnerabilities are introduced

We'll review your PR soon.

@github-actions github-actions Bot added documentation Improvements or additions to documentation dependencies security automation testing labels Nov 25, 2026
Codacy's Opengrep reports a subprocess call without a static string and
the xml import as it does for any script; both are false positives here
(a fixed argument list, and escaping only). nosemgrep notes sit beside
the existing nosec notes, matching enginescript-site-exporter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PDowney
PDowney merged commit 7680447 into main Nov 25, 2026
26 checks passed
@github-actions
github-actions Bot deleted the codacy-config-files branch November 25, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant